﻿using Module.Test.Domain.Models.Grpc;
using System;
using System.Collections.Generic;
using System.Linq;
using System.ServiceModel;
using System.Text;
using System.Threading;
using System.Threading.Tasks;

namespace Module.Test.Application.GrpcServices
{
    [ServiceContract(Namespace ="test")]
    public interface IPersonService
    {
        [OperationContract]
        Task<Person> Get(CancellationToken token = default);

        [OperationContract]
        Task<int> GetInt(CancellationToken token = default);
        /// <summary>
        /// 一元(请求/响应)
        /// </summary>
        /// <param name="fullName"></param>
        /// <param name="dateOfBirth"></param>
        /// <param name="addresses"></param>
        /// <param name="token"></param>
        /// <returns></returns>
        [OperationContract]
        Task<Person> CreatePersonAsync(string fullName, DateTime dateOfBirth, IList<Address> addresses, CancellationToken token = default);

        
        /// <summary>
        /// 客户端流式
        /// </summary>
        /// <param name="persons"></param>
        /// <param name="age"></param>
        /// <param name="token"></param>
        /// <returns></returns>
        [OperationContract]
        Task<Person> FindPersonOlderThan(IAsyncEnumerable<Person> persons, TimeSpan age, CancellationToken token = default);

        /// <summary>
        /// 服务器流式
        /// </summary>
        /// <param name="count"></param>
        /// <param name="minAge"></param>
        /// <param name="token"></param>
        /// <returns></returns>
        [OperationContract]
        IAsyncEnumerable<Person> GetRandomPersons(int count, TimeSpan minAge, CancellationToken token = default);


        /// <summary>
        /// 服务器流式
        /// </summary>
        /// <param name="country"></param>
        /// <param name="city"></param>
        /// <param name="street"></param>
        /// <param name="token"></param>
        /// <returns></returns>
        [OperationContract]
        Task<(int Count, Address Address, IAsyncEnumerable<Person> Persons)> GetListOfStreetResidents(string country, string city, string street, CancellationToken token = default);

       

        /// <summary>
        /// 带有外部参数的异步双工流调用
        /// </summary>
        /// <param name="persons"></param>
        /// <param name="age"></param>
        /// <param name="token"></param>
        /// <returns></returns>
        [OperationContract]
        IAsyncEnumerable<Person> FindPersonsYoungerThan(IAsyncEnumerable<Person> persons, TimeSpan age, CancellationToken token = default);

    }
}
